<%@page import="org.bank.dto.AccountTO"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Bank Web</title>
</head>
<body>
<jsp:include page="links.html"></jsp:include>
<form name="searchAccountForm" action="/BankWeb/BankServlet" method="POST">
<% 
AccountTO account = null;
try{
	account = (AccountTO) session.getAttribute("BankServlet.createResponse"); //checking if we are to present an account that has been found from a previous search.
}catch(Exception e){
	
}
if(account==null) //means that we are not in a response from a search
{
%>
<b>Please enter an account number:</b> <input type="text" name="accountNumber" /> 
<input type="hidden" name="action" value="SEARCH" /> 
<input type="submit" name="Submit" value="Search" /><br/>
<%
	Object obj = session.getAttribute("Status");
	if(obj != null) //if status is not null means that we are returning here after an operation
	{
		String createResp = null;
		try{
			createResp = (String) session.getAttribute("BankServlet.createResponse"); //checking if we are in a response from an error.
		}catch(Exception e){
			
		}
		if(createResp!=null) {
%>
		<center>
		<br/>
		<b>
		<%=createResp %>
		<%session.setAttribute("Status", null);//we reset the status to null so it does not influence other status checks %>
		<%session.setAttribute("BankServlet.createResponse", null); //we also reset the response so that it does not mess with other pages%>
		</b>
		</center>
<%
		} 
	}
} else {
%>
Details of account: <br/>
	<table>
		<tr>
		<td>Account Number:</td>
		<td><%=account.ID %></td>
		</tr>
		<tr>
		<td> First Name: </td>
		<td><%=account.firstName %></td> 
		</tr>
		<tr>
		<td> Last Name: </td>
		<td> <%=account.lastName %></td>
		</tr>
		<tr>
		<td> Address: </td>
		<td> <%=account.address %> </td>
		</tr>
		<tr>
		<td> Phone: </td>
		<td> <%=account.phone %> </td>
		</tr>
		<tr>
		<td> Balance: </td>
		<td> <%=account.balance %> </td>
		</tr>
	</table>
	<%session.setAttribute("BankServlet.createResponse", null); %>
<%
}%>
</form>
</body>
</html>